import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Information } from "src/entity/information.entity";
import { Repository } from "typeorm";

@Injectable()
export class InformationService {
  constructor(
    @InjectRepository(Information)
    private repository: Repository<Information>,
  ) {}

  async findAll(): Promise<Information[]> {
    return this.repository.find();
  }

  async findOne(id: number): Promise<Information> {
    return this.repository.findOneBy({ id });
  }
  
  async addOne(entity: Information) {
    return this.repository.insert(entity)
  }

  async updateOne(entity: Information) {
    return this.repository.save(entity)
  }

  async remove(id: number) {
    return this.repository.delete(id);
  }
}

